package leetcode.code0419;

import leetcode.IDebug;

public class Solution implements IDebug {

	private static final char X = 'X';

	public int countBattleships(char[][] board) {
		int ans = 0;
		int m = board.length;
		int n = board[0].length;
		if (board[0][0] == X) {
			ans = 1;
		}
		for (int i = 1; i < n; i++) {
			if (board[0][i] == X && board[0][i - 1] != X) {
				ans += 1;
			}
		}
		for (int i = 1; i < m; i++) {
			if (board[i][0] == X && board[i - 1][0] != X) {
				ans += 1;
			}
		}
		for (int i = 1; i < m; i++) {
			for (int j = 1; j < n; j++) {
				if (board[i][j] == X && board[i - 1][j] != X && board[i][j - 1] != X) {
					ans += 1;
				}
			}
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
